Copyright updates.
gpilots.o saroute.o navicache.o psitrex.o geoniche.o delgpl.o \
ozi.o nmea.o text.o html.o palmdoc.o
-FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o
+FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o
JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \
jeeps/gpsmath.o jeeps/gpsmem.o \
typedef struct {
geocache_type type;
geocache_container container;
+ int id; /* The decimal cache number */
int diff; /* (multiplied by ten internally) */
int terr; /* (likewise) */
time_t exported;
/*
Describe vectors containing filter operations.
- Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+ Copyright (C) 2002,2004 Robert Lipe, robertlipe@usa.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
extern filter_vecs_t polygon_vecs;
extern filter_vecs_t routesimple_vecs;
extern filter_vecs_t reverse_route_vecs;
+extern filter_vecs_t sort_vecs;
static
fl_vecs_t filter_vec_list[] = {
"reverse",
"Reverse stops within routes",
},
+ {
+ &sort_vecs,
+ "sort",
+ "Rearrange waypoints by resorting",
+ },
{
NULL,
NULL,
/*
- * written by robertlipe@usa.net
- */
+ Access gpsutil files.
+
+ Copyright (C) 2002, 2003, 2004 Robert Lipe, robertlipe@usa.net
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
#include "defs.h"
#include "magellan.h"
{
double lon,lat;
const char *icon_token;
+ char *tdesc = str_utf8_to_ascii(wpt->description);
icon_token = mag_find_token_from_descr(wpt->icon_descr);
lon < 0.0 ? 'W' : 'E',
wpt->altitude,
'm',
- wpt->description ? wpt->description : "",
+ wpt->description ? tdesc : "",
icon_token);
+
+ xfree(tdesc);
}
static void
tt_wpt_time,
tt_wpt_type,
tt_wpt_urlname,
+ tt_cache,
tt_cache_name,
tt_cache_container,
tt_cache_type,
{ tt_wpt_urlname, 0, "/gpx/wpt/urlname" },
{ tt_wpt_sym, 0, "/gpx/wpt/sym" },
{ tt_wpt_type, 1, "/gpx/wpt/type" },
+ { tt_cache, 1, "/gpx/wpt/groundspeak:cache" },
{ tt_cache_name, 1, "/gpx/wpt/groundspeak:cache/groundspeak:name" },
{ tt_cache_container, 1, "/gpx/wpt/groundspeak:cache/groundspeak:container" },
{ tt_cache_type, 1, "/gpx/wpt/groundspeak:cache/groundspeak:type" },
}
}
+static void
+tag_gs_cache(const char **attrv)
+{
+ const char **avp;
+
+ cache_descr_is_html = 0;
+ for (avp = &attrv[0]; *avp; avp+=2) {
+ if (strcmp(avp[0], "id") == 0) {
+ wpt_tmp->gc_data.id = atoi(avp[1]);
+ }
+ }
+}
+
static void
start_something_else(const char *el, const char **attrv)
{
case tt_unknown:
start_something_else(el, attr);
return;
+ case tt_cache:
+ tag_gs_cache(attr);
+ break;
case tt_cache_log_wpt:
if (opt_logpoint)
tag_log_wpt(attr);
+/*
+ Generate unique short names.
+
+ Copyright (C) 2003, 2004 Robert Lipe, robertlipe@usa.net
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
--- /dev/null
+/*
+ Arbitrary Sorting Filter(s)
+
+ Copyright (C) 2004 Robert Lipe, robertlipe@usa.net
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+#include "defs.h"
+
+extern queue waypt_head;
+
+typedef enum {
+ sm_unknown = 0,
+ sm_gcid,
+ sm_shortname,
+ sm_description
+} sort_mode_;
+
+sort_mode_ sort_mode = sm_shortname; /* How are we sorting these? */
+
+static char *opt_sm_gcid, *opt_sm_shortname, *opt_sm_description;
+
+static
+arglist_t sort_args[] = {
+ {"gcid", &opt_sm_gcid, "Sort by numeric geocache ID", ARGTYPE_BOOL },
+ {"shortname", &opt_sm_shortname, "Sort by waypoint short name", ARGTYPE_BOOL },
+ {"description", &opt_sm_description, "Sort by waypoint description", ARGTYPE_BOOL },
+ {0, 0, 0, 0}
+};
+
+static int
+sort_comp(const void * a, const void * b)
+{
+ const waypoint *x1 = *(waypoint **)a;
+ const waypoint *x2 = *(waypoint **)b;
+
+ switch (sort_mode) {
+ case sm_gcid: return x1->gc_data.id > x2->gc_data.id;
+ case sm_shortname: return strcmp (x1->shortname, x2->shortname);
+ case sm_description: return strcmp (x1->description, x2->description);
+ }
+}
+
+void
+sort_process(void)
+{
+ queue * elem, * tmp;
+ waypoint ** comp;
+ int i = 0, wc;
+
+ wc = waypt_count();
+
+ comp = xcalloc(wc, sizeof(*comp));
+
+ QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
+ comp[i] = (waypoint *)elem;
+ waypt_del(comp[i]); /* Pop this waypoint off the master Q */
+ i++;
+ }
+
+ qsort(comp, wc, sizeof(waypoint *), sort_comp);
+
+ /*
+ * Now re-add the list back.
+ */
+ for (i = 0; i < wc ; i++) {
+ waypt_add(comp[i]);
+ }
+
+ if (comp)
+ xfree(comp);
+}
+
+void
+sort_init(const char *args)
+{
+ if (opt_sm_gcid)
+ sort_mode = sm_gcid;
+ if (opt_sm_shortname)
+ sort_mode = sm_shortname;
+ if (opt_sm_description)
+ sort_mode = sm_description;
+}
+
+filter_vecs_t sort_vecs = {
+ sort_init,
+ sort_process,
+ NULL,
+ sort_args
+};